﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows;
using System.Windows.Data;

namespace BuyingSpree_HPV.Converter
{
    /// <summary>
    /// 0/1 隐藏显示转换器 1隐藏 0 显示
    /// </summary>
    public class FlagConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int resultPage;
            if (value != null && int.TryParse(value.ToString(), out resultPage))
            {
                switch (resultPage)
                {
                    case 0:
                        {
                            return Visibility.Visible;
                        }
                    case 1:
                        {
                            return Visibility.Collapsed;
                        }
                    case 2:
                        {
                            return Visibility.Hidden;
                        }
                    default:
                        return Visibility.Collapsed;
                }
            }
            return Visibility.Collapsed;

        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
